<template>
  <div>
    <header>
      <div class="pic" v-if="detailList.community">
        <h2>
          <i class="iconfont icon-fanhui" @click="$router.back()"></i
          ><span>{{ detailList.community }}</span>
        </h2>
        <img :src="imgPic" alt="" />
        <div class="look">
          <p>{{ detailList.title }}</p>
          <span
            class="desc"
            v-for="(item, index) in detailList.tags"
            :key="index"
          >
            {{ item }}
          </span>
        </div>
        <div class="price">
          <div>
            <span>{{ detailList.price }}<em>/月</em></span>
            <span>{{ detailList.roomType }}</span>
            <span>{{ detailList.size }}平米</span>
          </div>
          <p>
            <span>租金</span>
            <span>房型</span>
            <span>面积</span>
          </p>
        </div>
      </div>
    </header>
  </div>
</template>

<script>
// 请求地址:  'http://www.xiaoshuaipeng.com:8080/houses/{id}'
// 请求方式: get
import instance from '@/utils/request'
export default {
  name: 'DetailPage',
  data () {
    return {
      detailList: [],
      imgPic: []
    }
  },
  async created () {
    // console.log(this.$route.params.id)
    // const id = this.$route.query.id
    const id = this.$route.params.id
    const data = await instance.get(
      `/houses/${id}`
    )
    // console.log(data.body)
    this.detailList = data.body
    this.imgPic = 'http://www.xiaoshuaipeng.com:8080' + data.body.houseImg[0]
  }
}
</script>
<style>
i,
em {
  font-style: normal;
}
</style>
<style lang="less" scoped>
.pic {
  background-color: #fff;
  h2 {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 45px;
    background-color: rgba(0, 0, 0, 0.1);
    color: #fff;
    font-size: 16px;
    line-height: 45px;
    font-weight: 400;
    .iconfont {
      padding-left: 15px;
      font-size: 22px;
    }
    span {
      flex: 1;
      text-align: center;
    }
  }
  img {
    width: 100%;
    height: 252px;
  }
  .look {
    height: 89px;
    border-bottom: 1px solid #d6d6d6;
    padding-top: 15px;
    margin: 0 16px;
    p {
      font-size: 16px;
      color: #333;
    }
    .desc {
      width: 48px;
      height: 20px;
      color: #39becd;
      font-size: 12px;
      margin-top: 10px;
      margin-right: 3px;
      line-height: 20px;
      text-align: center;
      background-color: #e1f5f8;
    }
  }
  .price {
    height: 89px;
    margin: 0 16px;
    line-height: 70px;
    border-bottom: 1px solid #d6d6d6;
    font-size: 16px;
    font-weight: 700;
    color: #fa5741;
    div {
      display: flex;
      justify-content: space-around;
      height: 30px;
      em {
        font-size: 12px;
        font-style: initial;
      }
    }
    p {
      display: flex;
      justify-content: space-around;
      height: 30px;
      font-size: 13px;
      font-weight: 400;
      color: #999;
    }
  }
}
</style>
